'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {

  /* 获取路由中间件 */
  const counter = app.middleware.counter();

  const { router, controller } = app;
  /* newer parts: */
  // --------------------------------
  // 😎top router:
  // 对该页面使用路由中间件(counter)
  router.get('/', controller.home.index);
  router.get('/jspang', controller.jspang.indexPage);
  router.get('/jspangPageNameInUrl', counter, controller.jspang.indexPage);

  // test visit picture:
  // router.get('/getFile', controller.home.getFile);
  // router.get(`pic`, controller.image);
  router.get('/login', controller.home.login);
  router.post('/login', controller.home.doLogin);
  router.post('/logout', controller.home.logout);
  router.get('/jwt', controller.jwt.index);
  // operations of database(mysql)
  router.get("/addGirl", controller.girlsManage.addGirl);
  router.get("/delGirl", controller.girlsManage.delGirl);
  router.get("/updateGirl", controller.girlsManage.updateGirl);
  router.get("/getGirls", controller.girlsManage.getGirls);

  // helper extension:
  router.get('/baseHelper', controller.jspang.baseHelper);
  // response :set toke trial
  router.get('/newResponse', controller.jspang.newResponse);
  // request token:
  router.post("/newRequest", controller.jspang.newRequest);

  /* context extension test: */
  // router for context extension:
  router.get('/newContextGet', controller.jspang.newContextGet);
  // test the post mode to requset :
  router.post('/newContextPost', controller.jspang.newContextPost);


  router.post('/add', controller.jspang.add);
  router.post('/del', controller.jspang.del);
  router.post('/editor', controller.jspang.editor);
  router.post('/show', controller.jspang.show);

  router.get('/testGetGirl', controller.home.testGetGril);
  router.post('/addPost', controller.jspang.addPost);
  // set strict parameter format to pass defined in the router (it is more recommended.)
  router.get('/getGirl2/:name/:age', controller.jspang.getGirl2);

  /* // test url for this :  http://127.0.0.1:7001/getGirl?name=a&age=18
  expect: {"name":"a","age":"18"}  to show*/
  // router.get('/getGirl', controller.jspang.getGirl);

  /* old */
  // router.get('/getGirls', controller.jspang.getGirls);
  // router.get('/jspang', controller.home.jspang);



};
